package cn.wolfcode.luowowo.common.util;

import lombok.Getter;

@Getter
public enum RedisKey {

    //国内攻略key
    STRATEGY_CHINA_ZSET("strategy_china_zset", -1L),

    //国外攻略key
    STRATEGY_ABROAD_ZSET("strategy_abroad_zset", -1L),

    //热门攻略key
    STRATEGY_HOT_ZSET("strategy_hot_zset", -1L),

    //用户点赞攻略key
    USER_THUMBUP_TAG("user_thumbup_tag", -1L),


    //用户攻略收藏key
    USER_STRATEGY_FAVOR("user_strategy_favor", -1L),
    //用户游记收藏key
    USER_TRAVEL_FAVOR("user_travel_favor", -1L),

    //数据统计对象vo
    STRATEGY_STATIS_VO("strategy_statis_vo", -1L),
    //游记统计对象vo
    TRAVEL_STATIS_VO("travel_statis_vo", -1L),
    //收藏游记统计对象vo
    TRAVEL_COLLERTION_UID("travel_collertion_uid", -1L),
    //收藏攻略统计对象vo
    STRATEGY_COLLERTION_UID("strategy_collertion_uid", -1L),
    //收藏地点统计对象vo
    DEST_COLLERTION_UID("dest_collertion_uid", -1L),

    //用户
    USER_LOGIN_TOKEN("user_login_token", Consts.USER_INFO_TOKEN_VAI_TIME * 60L),

    //验证码枚举实例
    VERIFY_CODE("verify_code", Consts.VERIFY_CODE_VAI_TIME * 60L);

    private String prefix;//用作Redis key的前缀
    private Long time;//key值的失效时间, 单位秒

    private RedisKey(String prefix, Long time){
        this.prefix = prefix;
        this.time = time;
    }

    public String join(String...value){
        StringBuilder builder = new StringBuilder(50);
        builder.append(this.prefix);
        for (String val : value) {
            builder.append(":").append(val);
        }
        return builder.toString();
    }
}
